import java.util.Arrays;

/**
 * @program: 11.3.1
 * @description:
 * @author: 李鑫月
 * @create: 2021-11-03 21:01
 **/
public class MyArrayList {
    public int[] arr;
    public int usedsize;
    public MyArrayList(){
        this.arr=new int[10];
    }
    public void display(){
        for (int i = 0; i <this.usedsize ; i++) {
            System.out.print(this.arr[i]+" ");
        }
    }
    public int size(){
        return this.usedsize;
    }
    public boolean isfull(){
        return this.usedsize==this.arr.length;
    }
    public void add(int pos,int data){
        if(pos>usedsize||pos<0){
            return;
        }
        if(isfull()){
            arr=Arrays.copyOf(arr,arr.length*2);
        }
        if(this.usedsize==0) {
            this.arr[0]=data;
           this.usedsize++;
        }else {
            for (int i =this.usedsize-1; i >=pos ; i--) {
                this.arr[i+1]=this.arr[i];
            }
            this.arr[pos]=data;
            this.usedsize++;
        }


    }
    public boolean contains(int toFind){
        for (int i = 0; i <this.usedsize ; i++) {
            if(toFind==this.arr[i]){
                return true;
            }
        }
        return false;
    }
    public int search(int toFind) {
        for (int i = 0; i <this.usedsize ; i++) {
            if(toFind==this.arr[i]){
                return i;
            }
        }
        return -1;
    }
//    public boolean isEmpty(){
//
//
//    }
//    public void setPos(int pos, int value) {
//
//    }
//    public void remove(int toRemove) {
//
//    }
//    public void clear() {
//    }
}
